<template>
  <el-form style="width: 80%" :model="form">
    <el-form-item label="店员名" label-width="100px" prop="name">
        <el-input v-model="form.name"></el-input>
    </el-form-item>
    <el-form-item label="用户名" label-width="100px" prop="username">
        <el-input v-model="form.username" disabled></el-input>
    </el-form-item>
    <el-form-item label="密码" label-width="100px" prop="name">
        <el-input v-model="form.password"></el-input>
    </el-form-item>
    <el-form-item label="性别" label-width="100px" prop="gender">
        <el-radio-group v-model="form.gender">
        <el-radio :value="0">男</el-radio>
        <el-radio :value="1">女</el-radio>
        </el-radio-group>
    </el-form-item>
    <el-form-item label="手机号" label-width="100px" prop="phone">
        <el-input  v-model="form.phone"></el-input>
    </el-form-item>
    <el-form-item label="地址" label-width="100px" prop="address">
        <el-input v-model="form.address"></el-input>
    </el-form-item>
    <el-form-item label="生日" label-width="100px" prop="birthday">
        <el-date-picker
        v-model="form.birthday"
        type="date"
        placeholder="生日"
        size="small"
        />
    </el-form-item>
    <el-form-item label="备注信息" label-width="100px" prop="notes">
        <el-input
            v-model="form.notes"
            style="width: 240px"
            :rows="2"
            type="textarea"
            placeholder="备注信息"
        />
    </el-form-item>
  </el-form>
  <el-button type="primary" size="default" @click="confirm">
      提交
  </el-button>
</template>

<script setup>
import { ref, reactive } from 'vue'
import * as apiClerk from "@/api/personnel/clerk.js"
import { ElMessage } from 'element-plus'

const form = reactive({
  id: null,
  storeId: null,
  permission: null,
  name: null,
  username: null,
  password: null,
  gender: null,
  phone: null,
  address: null,
  birthday: null,
  notes: null,
})

const confirm = async () => {
  const result = await apiClerk.reqSelfUpdate(form)

  if (result != null) {
    ElMessage({
      message: '修改成功',
      type: 'success',
    })
  }
}

apiClerk.reqSelfGet().then(resp => {
  for (let k in form) {
    form[k] = resp.data[k]
  }
})
</script>

<style scoped lang="scss">
</style>